package com.sams.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sams.entity.SubsidizeManager;
import com.sams.entity.SubsidizeManagerExample;
import com.sams.entity.SubsidizeManagerExample.Criteria;
import com.sams.mapper.SubsidizeManagerMapper;
import com.sams.service.SubsidizeManagerService;

@Service
public class SubsidizeManagerServiceImpl implements SubsidizeManagerService{

	@Autowired
	private SubsidizeManagerMapper mapper;
	
	
	public PageInfo<SubsidizeManager> listSubsidize(int currentPage) {
		PageHelper.startPage(currentPage, 20);   
		
		SubsidizeManagerExample example = new SubsidizeManagerExample();
		Criteria createCriteria = example.createCriteria();
		 
		  //设置条件  xue
		 //createCriteria.andIdEqualTo(1);
		 
		// System.out.println("====="+mapper);
		List<SubsidizeManager> list =  mapper.selectByExample(example);
		
		
		PageInfo<SubsidizeManager> pageInfo = new PageInfo<SubsidizeManager>(list);
		//System.out.println("当前页："+pageInfo.getPageNum());
		//System.out.println("总记录数："+pageInfo.getPageSize());
		//System.out.println(pageInfo);
		
		return pageInfo;
	}

	public int add(SubsidizeManager sub) {
		return mapper.insert(sub);
	}

	public int update(SubsidizeManager sub) {
		return mapper.updateByPrimaryKey(sub);
	}

	

	public int delete(int id) {
		return mapper.deleteByPrimaryKey(id);
	}

}
